﻿#include <string>
#include <iostream>
#include "cfg.hpp"
#include "./testcase/test_temp_obstacles.hpp"
#include <Finder/NavHelper.h>
#include <Finder/ObsNavMesh.h>



void TestFindPos() {
	float stpos[3] = { 50.47,0.21,45.66 };
	float endpos[3] = { 168,10,98 };
	auto mesh = NavHelper::GetNavMesh(".\\level.bin");
	auto finder = NavHelper::GetFinder(mesh);
	int count=0;
	auto result = NavHelper::FindPath(finder, stpos[0], stpos[1], stpos[2], endpos[0], endpos[1], endpos[2], &count);
	printf("TestFindPos %d \n",count);
	for (int i = 0; i < count; i+=3)
	{
		printf("path i=%d %f %f %f \n", i,result[i+0], result[i + 1], result[i + 2]);
	}

}

void TestTOFindPos() {
	float stpos[3] = {96,38,49};
	float endpos[3] = { 97,38,47 };
	auto mesh = NavHelper::GetNavMeshTO(".\\level.bin.to");
	
	int count = 0;
	auto result = NavHelper::FindPathTO(mesh, stpos[0], stpos[1], stpos[2], endpos[0], endpos[1], endpos[2], &count);
	printf("TestFindPos %d \n", count);
	for (int i = 0; i < count; i += 3)
	{
		printf("path i=%d %f %f %f \n", i, result[i + 0], result[i + 1], result[i + 2]);
	}

}

void TestObsFindPos() {
	float stpos[3] = { 96,38,49 };
	float endpos[3] = { 97,38,47 };
	auto NavMesh = NavHelper::NewObsNavMesh(".\\level.bin.to", "");
	auto finder = NavHelper::NewObsPathFinder(NavMesh);
	int count = 0;
	auto result = NavHelper::ObsFindPath(finder, stpos[0], stpos[1], stpos[2], endpos[0], endpos[1], endpos[2], &count);
	printf("TestObsFindPos %d \n", count);
	for (int i = 0; i < count; i += 3)
	{
		printf("path i=%d %f %f %f \n", i, result[i + 0], result[i + 1], result[i + 2]);
	}
}

void TestObs() {
	auto* toNaveMesh = new ObsNavMesh();

	auto ok = toNaveMesh->LoadFile("E:\\gowork\\gameserver\\server\\res\\maps\\Map_FB_XinSG\\level.bin.to");
	//auto ok = toNaveMesh->LoadFile(".\\level.bin.to");
	printf("%d", ok);
	float centpos[3] = { 90,40,38 };
	float halfpos[3] = { 1,10,27 };
	float yawredian = 152;
	toNaveMesh->AddObbBox("temp", centpos[0], centpos[1], centpos[2], halfpos[0], halfpos[1], halfpos[2], yawredian);
	toNaveMesh->Update();
}

int main(int argn, char* argc[])
{
	printf("hello world.");
	TestTOFindPos();
	TestObsFindPos();
	//test_temp_obstacles::instance().test();
	return -1;
}